package com.hh.flow.service.impl;

import com.hh.flow.domain.FlowInsHis;
import com.hh.flow.mapper.FlowInsHisMapper;
import com.hh.flow.service.IFlowInsHisService;
import com.hh.mybatis.service.impl.BaseServiceImpl;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.hh.flow.domain.tables.FlowInsHisTableDef.flow_ins_his;

/**
 * 实例历史记录Service业务层处理
 *
 * @author hh
 * @date 2023-03-29
 */
@Service
public class FlowInsHisServiceImpl extends BaseServiceImpl<FlowInsHis> implements IFlowInsHisService {
    @Resource
    private FlowInsHisMapper insHisMapper;

    @Override
    public FlowInsHisMapper getBaseMapper() {
        return insHisMapper;
    }

    @Override
    public QueryWrapper buildWrapper(FlowInsHis flowInsHis) {
        QueryWrapper query = QueryWrapper.create()
                .where(flow_ins_his.node_from.eq(flowInsHis.getNodeFrom()))
                .and(flow_ins_his.node_from_name.like(flowInsHis.getNodeFromName()))
                .and(flow_ins_his.node_to.eq(flowInsHis.getNodeTo()))
                .and(flow_ins_his.node_to_name.like(flowInsHis.getNodeToName()))
                .and(flow_ins_his.user_code.eq(flowInsHis.getUserCode()))
                .and(flow_ins_his.user_name.like(flowInsHis.getUserName()))
                .and(flow_ins_his.instance_id.eq(flowInsHis.getInstanceId()))
                .and(flow_ins_his.message.eq(flowInsHis.getMessage()))
                .and(flow_ins_his.condition_value.eq(flowInsHis.getConditionValue()));
        return query;
    }

    @Override
    public List<FlowInsHis> queryByInstanceId(List<Long> instanceIds) {
        return list(flow_ins_his.instance_id.in(instanceIds));
    }

}
